<div class="rightcontent rc-bg-grey">
    <div class="rc-pagepadding">
        <div class="rc-pannel rc-searchbox">
            <form class="layui-form " method="get" action="/admin/cnf/UserIntegralRule/index">
                <div class="rc-flex-vertical-center rc-searchbox">
                    <div class="layui-inline ">
                        <label class="layui-form-label">规则名</label>
                        <div class="layui-input-inline ">
                            <input type="text" name="title" placeholder="" value="<?php echo request()->get('title', ''); ?>" autocomplete="off" class="layui-input">
                        </div>
                    </div>



                    <div class="layui-inline">
                        <div class="layui-form-label">
                            <button type="submit" class="layui-btn layui-btn-sm layui-btn-primary"><i class="iconfont">&#xeafe;</i> 搜索</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>



        <div class=" rc-pannel rc-margin-top-default">
            <div class=" rc-pannel-header">
                <div class="rc-flex layui-form toolbar rc-flex-justify-between">
                    <div class=" rc-flex rc-flex-vertical-center ">

                    </div>
                    <div>


                        <a href="/admin/cnf/UserIntegralRule/add" class="layui-btn layui-btn-primary layui-btn-sm" id="managefield"><i class="iconfont">&#xe60e;</i> 添加规则</a>

                    </div>
                </div>


            </div>


            <div class="rc-pannel-body layui-form rc-pagepadding">
                <table class="layui-table" id="sort">
                    <colgroup>
                        <col>
                        <col>
                        <col>
                        <col>
                        <col>
                        <col style="width: 240px;">
                    </colgroup>
                    <thead>
                        <tr>
                            <th>规则名</th>
                            <th>挂载事件动作</th>
                            <th>增长/扣除</th>
                            <th>积分</th>
                            <th>每日限额
                                <i class="layui-icon layui-icon-question rc-tips rc-pointer" message="每日每用户最多增长多少积分"></i>
                            </th>
                            <th>总限额
                                <i class="layui-icon layui-icon-question rc-tips rc-pointer" message="整个系统内每用户最多增长多少积分"></i>
                            </th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>

                        <?php
                        foreach ($rules as $key => $rule) {
                        ?>
                            <tr>
                                <td><?php echo $rule->title; ?></td>
                                <td><?php echo $rule->hooktitle.' / '. $rule->hookident; ?></td>
                                <td><?php echo $rule->addsub == 1 ? '增长' : '扣除'; ?></td>
                                <td><?php echo $rule->integral; ?></td>
                                <td><?php echo $rule->daylimit == 0 ? '不限' : $rule->daylimit; ?></td>
                                <td><?php echo $rule->alllimit == 0 ? '不限' : $rule->alllimit; ?></td>
                                <td>
                                    <div class="rc-opbar">
                                        <a class="info" href="/admin/cnf/UserIntegralRule/edit?id=<?php echo $rule->id ?>"><i class="iconfont">&#xe606;</i> 编辑</a>
                                        <a class="error delete" ruleid="<?php echo $rule->id ?>"><i class="iconfont">&#xe607;</i> 删除 </a>
                                    </div>
                                </td>
                            </tr>
                        <?php
                        }
                        ?>


                    </tbody>
                </table>


            </div>


            <div class="rc-pannel-footer">
                <div class="pagebar" style="text-align: right;">
                    <?php echo paginator($rules->total(), 20); ?>
                </div>

            </div>

        </div>
    </div>




</div>


<script>
    layui.use(function() {
        var layer = layui.layer;
        $('.delete').click(function() {
            var id = $(this).attr('ruleid');
            layer.confirm('确定要删除么？', {
                icon: 3
            }, function() {
                $.ajax({
                    url: '/admin/cnf/UserIntegralRule/delete?id=' + id, //请求路径
                    type: "POST", //请求方式
                    success: function(data) {
                        if (data.code == 0) {
                            window.location.reload();
                        } else {
                            toastr_error(data.message);
                        }
                    },
                    error: function() {

                    },

                });


            }, function() {



            });
        });

    });
</script>